package com.wannengbang.cloudleader.homepage.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.wannengbang.cloudleader.R;
import com.wannengbang.cloudleader.bean.QuotaListBean;
import com.wannengbang.cloudleader.bean.UserInfoBean;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Author: HWC
 * Description: 合伙人列表
 */
public class TeamDetailsListAdapter extends RecyclerView.Adapter<TeamDetailsListAdapter.ViewHolder> {

    private List<QuotaListBean.DataBean.ItemListBean> listsBeans;
    private Context context;
    private UserInfoBean userInfoBean;

    public TeamDetailsListAdapter(List<QuotaListBean.DataBean.ItemListBean> listsBeans) {
        this.listsBeans = listsBeans;
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int viewType) {
        context = viewGroup.getContext();
        View inflate = LayoutInflater.from(context).inflate(R.layout.item_team_details_list, viewGroup, false);
        ViewHolder viewHolder = new ViewHolder(inflate);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        QuotaListBean.DataBean.ItemListBean dataBean = listsBeans.get(position);

        holder.tvNumber.setText(dataBean.getId() + "");
        holder.tvIsFulfil.setText(dataBean.getIs_fulfil() == 0 ? "未完成" : "已完成：" + dataBean.getYield_date() + "(" + dataBean.getYa_name() + ")");
    }

    @Override
    public int getItemCount() {
        return listsBeans.size() == 0 ? 0 : listsBeans.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.tv_number)
        TextView tvNumber;
        @BindView(R.id.tv_is_fulfil)
        TextView tvIsFulfil;

        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
}
